﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommunityServer.WebServices.Common;
using CommunityServer.WebServices.Groups;
using CommunityServer.WebServices.Membership;

namespace CommunityServer.Membership
{
    public class Groups
    {
        public void AddMembertoGroup(CommunityServer.Groups.NENAAffiliates  enumAffiliate,
            int intUserId, MembershipType enumMembershipType)
        {
            GroupsService service = Services.Groups.GetGroupService();
            var oMember = service.GetGroupMember(Convert.ToInt32(enumAffiliate), intUserId);
            var oMembers = service.GetGroupMembers(Convert.ToInt32(enumAffiliate));
            foreach (Member oIterate in oMembers)
            {
                if (oIterate.Id == oMember.Id)
                    return;
            }
            //oMembers.Find(oMember);

            service.AddGroupMember(Convert.ToInt32(enumAffiliate), intUserId, enumMembershipType);
        }
    }
}
